<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function add(){
				let num1=document.getElementById("num1").value-0
				let num2=document.getElementById("num2").value-0
				//判断没有输入的情况
				
				
				//判断输入内容不是数字
				if(isNaN(num1)||isNaN(num2)){
					document.getElementById("num3").value="只能输入数字"
					return;
				}
				//判断除数是0的情况
				let num3=num1+num2
				document.getElementById("num3").value=num3.toFixed(15)-0
			}
			function sub(){
				let num1=document.getElementById("num1").value-0
				let num2=document.getElementById("num2").value-0
				let num3=num1-num2
				document.getElementById("num3").value=num3
			}
			function mul(){
				let num1=document.getElementById("num1").value-0
				let num2=document.getElementById("num2").value-0
				let num3=num1*num2
				document.getElementById("num3").value=num3
			}
			function div(){
				let num1=document.getElementById("num1").value-0
				let num2=document.getElementById("num2").value-0
				let num3=num1/num2
				if(!isFinite(num3)){
					document.getElementById("num3").value="除数不能为0"
					return;
				}
				document.getElementById("num3").value=num3
			}
		</script>
	</head>
	<body>
		第一个数：<input type="text" id="num1" /><br>
		第二个数：<input type="text" id="num2" /><br>
		<button onclick="add()">+</button>
		<button onclick="sub()">-</button>
		<button onclick="mul()">*</button>
		<button onclick="div()">/</button><br>
		计算结果：<input type="text" id="num3" /><br>
	</body>
</html>
